package com.yc.myspringboot.aop.demo2;

import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.JdkRegexpMethodPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InterceptorAnnotationConfig {

	@Bean
	public DefaultPointcutAdvisor defaultPointcutAdvisor3() {
		TracingInterceptor interceptor = new TracingInterceptor();

		// AnnotationMatchingPointcut pointcut = new
		// AnnotationMatchingPointcut(HfiTrace.class, true);
		JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
		pointcut.setPatterns("com.yc.myspringboot.service.d2.*");

		// 配置增强类advisor
		DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
		advisor.setPointcut(pointcut);
		advisor.setAdvice(interceptor);
		return advisor;
	}
}
